package com.haipumi.servlets.backadmin;

import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.haipumi.beans.DataGrid;
import com.haipumi.beans.haipumi_exchangelist;
import com.haipumi.biz.IBackExchangeBiz;
import com.haipumi.biz.impl.BackExchangeBizImpl;
import com.haipumi.servlets.CommonServlet;
import com.haipumi.utils.RequestUtil;

public class BackExchangeServlet extends CommonServlet {

	IBackExchangeBiz ibeb=new BackExchangeBizImpl();
	/**
	 * 
	 */
	private static final long serialVersionUID = -7111582496084921260L;

	public void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		String op=null;
		op=request.getParameter("op");
		if("findallexchangelist".equals(op)){
			findallexchangelist(request,response);
		}else if("updateexchangelist".equals(op)){
			updateexchangelist(request,response);
		}
	}

	private void updateexchangelist(HttpServletRequest request,
			HttpServletResponse response) {
		haipumi_exchangelist exchangelist =RequestUtil.parseRequest(request, haipumi_exchangelist.class);
		haipumi_exchangelist backexchangelist=ibeb.updateexchangelist(exchangelist);
		super.outData(response, backexchangelist);
	}

	private void findallexchangelist(HttpServletRequest request,
			HttpServletResponse response) {
		List<haipumi_exchangelist>exchangelist=null;
		exchangelist=ibeb.findallexchangelist();
		int r=0;
		r=ibeb.countAllexchangelist();
		DataGrid dg=new DataGrid();
		dg.setRows(exchangelist);
		dg.setTotal(r);
		super.outData(response, dg);
	}

}
